package com.cscw.caishiquan.httpclientDemo;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;

public class PostDataDemo {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws HttpException 
	 */
	public static void main(String[] args) throws HttpException, IOException {
		HttpClient client = new HttpClient();

		client.getHostConfiguration().setHost("jwgldx.gdut.edu.cn", 80, "http");

		PostMethod post = new PostMethod(
				"/(aas55p45dafjic2pphaga555)/default2.aspx");//将要跳转的页面

		String iden = "学生";
		String viewstate = "dDw4ODUxNDk4MDQ7Oz7WV00OyMIVUlZ7G8UTWqES9TW+cQ==";

		NameValuePair[] postData = {
				new NameValuePair("__VIEWSTATE", viewstate),
				new NameValuePair("TextBox1", userid),
				new NameValuePair("TextBox2", password),
				new NameValuePair("RadioButtonList1", iden),
				new NameValuePair("Button1", ""),
				new NameValuePair("lbLanguage", "") };

		post.setRequestBody(postData);
		client.executeMethod(post);
		post.releaseConnection();

	}

}
